package org.csu.mypetstore.service;

import org.csu.mypetstore.domain.CartItem;
import org.csu.mypetstore.domain.Order;
import org.csu.mypetstore.domain.OrderList;
import org.csu.mypetstore.persistence.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class OrderService {

    @Autowired
    OrderMapper orderMapper;

    public void insertOrderCart(CartItem cartItem) {
        orderMapper.insertOrderCart(cartItem);
    }

    public void insertOrder(Order order) {
        orderMapper.insertOrder(order);
    }

    public void updateOrderList(String orderId, String username) {
        orderMapper.updateOrderList(orderId,username);
    }

    public ArrayList<Order> searchOrder(String username) {
       return orderMapper.searchOrder(username);
    }

    public Order searchOrderByorderID(String orderId) {
        return orderMapper.searchOrderByorderID(orderId);
    }

    public ArrayList<CartItem> searchOrderCart(String orderId, String username) {
        return orderMapper.searchOrderCart(orderId,username);
    }

    public ArrayList<Order> getOrderList() {
        return orderMapper.getOrderList();
    }

    public void updateOrder(Order order) {
        orderMapper.updateOrder(order);
    }

    public void deleteOrder(String orderId) {
        orderMapper.deleteOrder(orderId);
    }

    public void deleteOrderCart(String orderId) {
        orderMapper.dateleOrderCart(orderId);
    }

    public void updateDeliver(Order order) {
        orderMapper.updateDeliver(order);
    }
}
